home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver25.zip / SOURCE.ZIP / Drawwnd.cpp next >
C/C++ Source or Header  |  1997-07-21  |  2KB  |  97 lines

  1. // drawwnd.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Saver.h"
  6. #include "drawwnd.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. LPCTSTR CDrawWnd::m_lpszClassName = NULL;
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDrawWnd
  17.  
  18. CDrawWnd::CDrawWnd(BOOL bAutoDelete)
  19. {
  20.     init=0;
  21.     m_bAutoDelete = bAutoDelete;
  22. }
  23.  
  24. CDrawWnd::~CDrawWnd()
  25. {
  26. }
  27.  
  28.  
  29. BEGIN_MESSAGE_MAP(CDrawWnd, CWnd)
  30.     //{{AFX_MSG_MAP(CDrawWnd)
  31.     ON_WM_PAINT()
  32.     ON_WM_CREATE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CDrawWnd message handlers
  38.  
  39. void CDrawWnd::OnPaint() 
  40. {
  41.     if(!init)  // first message is for window updates
  42.     {
  43.         CPaintDC dc(this); // device context for painting
  44.         CBrush brush(RGB(0,0,0));
  45.         CRect rect;
  46.         GetClientRect(rect);
  47.         dc.FillRect(&rect, &brush);
  48.         init++;
  49.     }
  50. //    else
  51.     {
  52.         probe.run();
  53.         Sleep(4);
  54.         Invalidate(FALSE);
  55.     }        
  56.     // Do not call CWnd::OnPaint() for painting messages
  57. }
  58.  
  59. int CDrawWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  60. {
  61.     if (CWnd::OnCreate(lpCreateStruct) == -1)
  62.         return -1;
  63.     return 0;
  64. }
  65.  
  66. BOOL CDrawWnd::Create(DWORD dwExStyle, DWORD dwStyle, const RECT& rect, 
  67.     CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
  68. {
  69.     // Register a class with no cursor
  70.     if (m_lpszClassName == NULL)
  71.     {
  72.         m_lpszClassName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,
  73.             ::LoadCursor(AfxGetResourceHandle(), 
  74.             MAKEINTRESOURCE(IDC_NULLCURSOR)));
  75.     }
  76.  
  77.     dwStyle |= WS_VISIBLE;
  78. /*
  79.     int x1, y1;
  80.     x1=(rect.right-rect.left-640)/2; if(x1<0) x1=0;
  81.     y1=(rect.bottom-rect.top-480)/2; if(y1<0) y1=0;
  82. */
  83.     return 
  84.         CreateEx(dwExStyle, m_lpszClassName, _T(""), dwStyle, 
  85.             rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 
  86.             pParentWnd->GetSafeHwnd(), NULL, NULL );
  87. }
  88.  
  89. void CDrawWnd::PostNcDestroy() 
  90.  
  91. {
  92.     if (m_bAutoDelete)
  93.         delete this;
  94. }
  95.  
  96. /****************************************************************************/
  97.